package com.portal.portal.config.service;

import java.util.HashSet;
import java.util.Set;

import javax.servlet.ServletContext;

import com.portal.portal.config.DriverResourceConfig;
import com.portal.util.constants.ServletAttributeKeys;
import com.portal.util.exception.PortalDriverConfigurationException;

public class DriverWindowStateServiceImpl implements DriverWindowStateService {

  private Set<String> portalSupportedWindowStates = new HashSet<String>(3);

  public void destroy() throws PortalDriverConfigurationException {
    portalSupportedWindowStates = null;
  }

  public void init(ServletContext ctx) throws PortalDriverConfigurationException {
    DriverResourceConfig driverResourceConfig = (DriverResourceConfig) ctx.getAttribute(ServletAttributeKeys.DRIVER_RESOURCE_CONFIG);
    if (driverResourceConfig != null) {
      portalSupportedWindowStates = driverResourceConfig.getSupportedWindowStates();
    } else {
      throw new PortalDriverConfigurationException("cannot get supported window mode from config file");
    }
  }

  public Set<String> getSupportedWindowStates() {
    return portalSupportedWindowStates;
  }

}
